import { combineReducers } from "../libs/mRedux";
import { RECEIVE_USER, RESET_USER } from "./action-type";

//管理count状态数据的reducer
function count(state = 1, action) {
  switch (action.type) {
    case "INCREMENT":
      return state + action.data;
    case "DECREMENT":
      return state - action.data;
    default:
      return state;
  }
}

//登录的用户user
function user(state = {}, action) {
  switch (action.type) {
    case RECEIVE_USER:
      return action.user;
    case RESET_USER:
      return {};
    default:
      return state;
  }
}

export default combineReducers({
  count,
  user
});
